#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
int main()
{
    int s = 0, v = 0;
    scanf("%d %d", &s, &v);
    int time = 8 * 60 + 0;
    int m = s / v;
    if (s % v) m++;
    time = time - 10 - m;
    printf("%02d %02d", time / 60, time % 60);
    return 0;
}